/*
 * CompoundArrayPlan.java
 * 
 * Copyright 2004 Christoph Csallner and Yannis Smaragdakis.
 */
package edu.gatech.cc.cnc.plans.stmt;

import edu.gatech.cc.jcrasher.plans.expr.ArrayCreateAndInit;
import edu.gatech.cc.jcrasher.plans.expr.Variable;
import edu.gatech.cc.jcrasher.plans.stmt.Block;
import edu.gatech.cc.jcrasher.plans.stmt.BlockStatement;
import edu.gatech.cc.jcrasher.plans.stmt.LocalVariableDeclarationStatement;

/**
 * Sequence of statements creating an array instance.
 * 
 * @param <T> type of created array instance.
 * 
 * @author csallner@gatech.edu (Christoph Csallner)
 */
public class ArrayCreatingBlockStatementSequence<T> extends ReferenceVariableCreatingBlockStatementSequence<T> {
	
	/**
	 * Constructor: C id = createInstance(); id.set(p1); id.set(p2); 
	 */	
	public ArrayCreatingBlockStatementSequence(
      Class<?> testeeType,
      Block<?> enclosingBlock,
      Variable<T> variable,
      BlockStatement<?>[] paramPlans)
  {
		super(enclosingBlock, variable, paramPlans);  //A a1 = ...; A a2 = ...;
		
		/* A[] a = A[]{a1, a2}; */
		ArrayCreateAndInit<T> array = new ArrayCreateAndInit<T>(
        variable.getReturnType(),
        testeeType);
		array.setComponentPlans(localNames); //a1, a2
		super.statements.add(new LocalVariableDeclarationStatement<T>(name, array));
	}

}
